home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Panel;
- import java.awt.Rectangle;
- import java.awt.image.ImageObserver;
-
- public class SPPanel2 extends Panel {
- AudioClip theAudioClip;
- boolean loopAudioClip;
- boolean autoPlay = false;
- boolean showButtons = false;
- Button playButton;
- Button stopButton;
- String playLabel;
- String stopLabel;
- Color bkColor;
- Image bkImage;
- Image osImage;
- Graphics osg;
- // $FF: renamed from: fm java.awt.FontMetrics
- FontMetrics field_0;
- int fontHeight;
- int playX;
- int playY;
- int playWidth;
- int playHeight;
- int stopX;
- int stopY;
- int stopWidth;
- int stopHeight;
- Rectangle playRect;
- Rectangle stopRect;
- boolean drawPlayRect = false;
- boolean drawStopRect = false;
- boolean pressPlay = false;
- boolean pressStop = false;
-
- public SPPanel2(Applet var1, int var2) {
- this.GetParameters(var1, var2);
- if (this.showButtons) {
- this.playButton = new Button(this.playLabel);
- this.stopButton = new Button(this.stopLabel);
- }
-
- this.playRect = new Rectangle();
- this.stopRect = new Rectangle();
- }
-
- void GetParameters(Applet var1, int var2) {
- String var3 = var1.getParameter("spSound" + var2);
- if (var3 != null) {
- this.theAudioClip = var1.getAudioClip(var1.getCodeBase(), var3);
- }
-
- var3 = var1.getParameter("spLoopSound" + var2);
- this.loopAudioClip = AppletParam2.GetBoolean(var3, false);
- var3 = var1.getParameter("spAutoPlay" + var2);
- this.autoPlay = AppletParam2.GetBoolean(var3, false);
- var3 = var1.getParameter("spShowButtons" + var2);
- this.showButtons = AppletParam2.GetBoolean(var3, false);
- var3 = var1.getParameter("spPlayLabel" + var2);
- this.playLabel = AppletParam2.GetString(var3, "Play");
- var3 = var1.getParameter("spStopLabel" + var2);
- this.stopLabel = AppletParam2.GetString(var3, "Stop");
- var3 = var1.getParameter("spBkColor" + var2);
- this.bkColor = AppletParam2.GetColor(var3, (Color)null);
- if (this.bkColor != null) {
- ((Component)this).setBackground(this.bkColor);
- }
-
- var3 = var1.getParameter("spBkImage" + var2);
- this.bkImage = AppletParam2.GetImage(var1, var3);
- }
-
- public boolean mouseMove(Event var1, int var2, int var3) {
- boolean var4 = this.playRect.inside(var2, var3);
- boolean var5 = this.stopRect.inside(var2, var3);
- if (this.drawPlayRect != var4) {
- this.drawPlayRect = var4;
- ((Component)this).repaint();
- }
-
- if (this.drawStopRect != var5) {
- this.drawStopRect = var5;
- ((Component)this).repaint();
- }
-
- return true;
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- this.pressPlay = false;
- this.pressStop = false;
- ((Component)this).repaint();
- return true;
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- if (this.playRect.inside(var2, var3)) {
- this.pressPlay = true;
- this.pressStop = false;
- ((Component)this).repaint();
- if (this.theAudioClip != null) {
- if (this.loopAudioClip) {
- this.theAudioClip.loop();
- } else {
- this.theAudioClip.play();
- }
- }
- }
-
- if (this.stopRect.inside(var2, var3)) {
- this.pressPlay = false;
- this.pressStop = true;
- ((Component)this).repaint();
- if (this.theAudioClip != null) {
- this.theAudioClip.stop();
- }
- }
-
- return true;
- }
-
- public synchronized void reshape(int var1, int var2, int var3, int var4) {
- super.reshape(var1, var2, var3, var4);
- this.osImage = null;
- this.osg = null;
- }
-
- public Dimension minimumSize() {
- return new Dimension(10, 10);
- }
-
- public Dimension preferredSize() {
- return new Dimension(10, 10);
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
-
- public void paint(Graphics var1) {
- if (this.osImage == null) {
- this.osImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
- this.osg = this.osImage.getGraphics();
- }
-
- this.osg.setColor(((Component)this).getBackground());
- this.osg.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- if (this.bkImage != null) {
- int var2 = this.bkImage.getWidth(this);
- int var3 = this.bkImage.getHeight(this);
- int var4 = ((Component)this).size().width / var2;
- int var5 = ((Component)this).size().height / var3;
- ++var4;
- ++var5;
-
- for(int var6 = 0; var6 < var5; ++var6) {
- for(int var7 = 0; var7 < var4; ++var7) {
- this.osg.drawImage(this.bkImage, var7 * var2, var6 * var3, this);
- }
- }
- }
-
- if (this.showButtons) {
- this.field_0 = ((Component)this).getFontMetrics(((Component)this).getFont());
- this.playWidth = this.field_0.stringWidth(this.playLabel) + 8;
- this.stopWidth = this.field_0.stringWidth(this.stopLabel) + 8;
- this.playHeight = this.stopHeight = this.field_0.getHeight() + 8;
- int var8 = ((Component)this).size().width / 2 - (this.playWidth + this.stopWidth + 10) / 2;
- int var9 = ((Component)this).size().height / 2 - this.playHeight / 2;
- this.playX = var8;
- this.playY = var9;
- this.stopX = this.playX + this.playWidth + 10;
- this.stopY = var9;
- this.playRect.reshape(this.playX, this.playY, this.playWidth, this.playHeight);
- this.stopRect.reshape(this.stopX, this.stopY, this.stopWidth, this.stopHeight);
- if (this.drawPlayRect) {
- if (this.pressPlay) {
- this.osg.setColor(Color.black);
- } else {
- this.osg.setColor(Color.white);
- }
-
- this.osg.drawLine(this.playX, this.playY, this.playX + this.playWidth - 1, this.playY);
- this.osg.drawLine(this.playX, this.playY, this.playX, this.playY + this.playHeight - 1);
- if (this.pressPlay) {
- this.osg.setColor(Color.white);
- } else {
- this.osg.setColor(Color.black);
- }
-
- this.osg.drawLine(this.playX, this.playY + this.playHeight - 1, this.playX + this.playWidth - 1, this.playY + this.playHeight - 1);
- this.osg.drawLine(this.playX + this.playWidth - 1, this.playY, this.playX + this.playWidth - 1, this.playY + this.playHeight - 1);
- }
-
- this.osg.setColor(Color.black);
- this.osg.drawString(this.playLabel, this.playX + 4, this.playY + this.playHeight - this.field_0.getDescent() - 4);
- if (this.drawStopRect) {
- if (this.pressStop) {
- this.osg.setColor(Color.black);
- } else {
- this.osg.setColor(Color.white);
- }
-
- this.osg.drawLine(this.stopX, this.stopY, this.stopX + this.stopWidth - 1, this.stopY);
- this.osg.drawLine(this.stopX, this.stopY, this.stopX, this.stopY + this.stopHeight - 1);
- if (this.pressStop) {
- this.osg.setColor(Color.white);
- } else {
- this.osg.setColor(Color.black);
- }
-
- this.osg.drawLine(this.stopX, this.stopY + this.stopHeight - 1, this.stopX + this.stopWidth - 1, this.stopY + this.stopHeight - 1);
- this.osg.drawLine(this.stopX + this.stopWidth - 1, this.stopY, this.stopX + this.stopWidth - 1, this.stopY + this.stopHeight - 1);
- }
-
- this.osg.setColor(Color.black);
- this.osg.drawString(this.stopLabel, this.stopX + 4, this.stopY + this.stopHeight - this.field_0.getDescent() - 4);
- }
-
- var1.drawImage(this.osImage, 0, 0, (ImageObserver)null);
- }
-
- public void Start() {
- if (this.theAudioClip != null) {
- if (this.loopAudioClip) {
- this.theAudioClip.loop();
- return;
- }
-
- if (this.autoPlay) {
- this.theAudioClip.play();
- }
- }
-
- }
-
- public void Stop() {
- if (this.theAudioClip != null) {
- this.theAudioClip.stop();
- }
-
- }
- }
-